import { defineConfig } from 'vitepress'
import vueJsx from "@vitejs/plugin-vue-jsx"
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {NaiveUiResolver} from "unplugin-vue-components/resolvers";
import {fileURLToPath, URL} from 'node:url'
export default defineConfig({
  vite: {
    ssr: {
      noExternal: ['naive-ui']
    },
    // Vite 配置选项
    plugins: [
      vueJsx(),
      AutoImport({
        dts: '../auto-imports.d.ts',
        imports: [
          'vue',
          {
            'naive-ui': [
              'useDialog',
              'useMessage',
              'useNotification',
              'useLoadingBar'
            ]
          }
        ],
      }),
      Components({
        dts: '../components.d.ts',
        resolvers: [NaiveUiResolver()]
      })
    ],
    publicDir: '../public',  
    server: {
      host: '0.0.0.0',
      port: 8100,
    }
  },
  title: "百业通组件库",
  description: "百业通组件库",
  themeConfig: {
    logo: '/icon.png',
    
    // 文档页脚文本配置
    lastUpdatedText: '上次更新',
    returnToTopLabel: '返回顶部',
    docFooter: {
      prev: '上一页',
      next: '下一页'
    },
    outline: {
      level: "deep", // 右侧大纲标题层级
      label: "目录", // 右侧大纲标题文本配置
    },

    search: {
      provider: 'local',
      options: {
        locales: {
          /* 默认语言 */
          root: {
            translations: {
              button: {
                buttonText: "搜索",
                buttonAriaLabel: "搜索文档",
              },
              modal: {
                noResultsText: "无法找到相关结果",
                resetButtonTitle: "清除查询结果",
                footer: {
                  selectText: "选择",
                  navigateText: "切换",
                },
              },
            },
          },
        }
      }
    },
    
    nav: [
      { text: '指南', link: '/guide/introduction' },
      { text: '组件库', link: '/components/app-router-view' }
    ],

    sidebar: {
      '/guide/': [
        {
          text: '',
          items: [
            { text: '介绍', link: '/guide/introduction' },
            { text: '安装组件', link: '/guide/installation' },
          ]
        },
      ],
      '/components/': [
        {
          text: '应用组件 ',
          items: [
            { text: '路由视图 AppRouterView', link: '/components/app-router-view' },
          ]
        },
        {
          text: '基础组件 ',
          items: [
            { text: '提交等待 ButtonLoading', link: '/components/button-loading' },
            { text: '弹出确认 ButtonPopconfirm', link: '/components/button-popconfirm' },
            { text: '弹窗等待 DialogLoading', link: '/components/dialog-loading' },
            { text: '上传图片 UploadImage', link: '/components/upload-image' },
            { text: '上传多张图片 UploadImageMultiple', link: '/components/upload-image-multiple' },
            { text: '上传文件 UploadFile', link: '/components/upload-file' },
            { text: '上传表格 UploadExcel', link: '/components/upload-excel' },
            { text: '弹窗上传表格 UploadExcelPopup', link: '/components/upload-excel-popup' },
          ]
        },
        {
          text: '业务组件 ',
          items: [
            { text: '表单搜索 FormSearch', link: '/components/form-search' },
            { text: '表格卡片 TableCard', link: '/components/table-card' },
            { text: '表格操作 TableAction', link: '/components/table-action' },
            { text: '表格列选择 TableColumnSelect', link: '/components/table-column-select' },
            { text: '表格状态 TableStatus', link: '/components/table-status' },
          ]
        },
        {
          text: '工具函数 ',
          items: [
            { text: '加密 crypto', link: '/components/crypto' },
            { text: '勾子函数 hooks', link: '/components/hooks' },
          ]
        },
      ],
    },

    socialLinks: [
      { icon: 'github', link: 'https://gitee.com/ali-coffee/byt-components' }
    ],

  },
  
  srcDir: './src'
})
